/********************************************
 * 功能说明: 
 * 模块名称: 
 * 系统名称: 
 * 软件版权: 北京银杉金服科技有限公司
 * 系统版本: 1.0.0
 * 开发人员: zhangfb
 * 开发时间: 2018/9/15 0:53
 * 审核人员: 
 * 相关文档: 
 * 修改记录: 修改日期 修改人员 修改说明
 *********************************************/
package com.hyacinth.controller;

import com.hyacinth.annotation.LogAnnotation;
import com.hyacinth.constant.LogTypeEnum;
import com.hyacinth.dto.SystemDto;
import com.hyacinth.entity.System;
import com.hyacinth.service.SystemService;
import com.hyacinth.util.validator.HyValidatorFactory;
import com.hyacinth.wapper.WrapMapper;
import com.hyacinth.wapper.Wrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zhangfb
 * @version 1.0.0.1
 * @since JDK 1.8
 */
@Slf4j
@RestController
@RequestMapping(value = "base/system", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class SystemController extends BaseController{

    private final SystemService systemService;

    @Autowired
    public SystemController(SystemService systemService) {
        this.systemService = systemService;
    }

    /**
     * 新增系统
     * @param system 系统对象
     * @return 结果封装
     */
    @LogAnnotation(logType = LogTypeEnum.INTERFACE_LOG, isSaveReqData = true, isSaveRespData = true, desc = "新增系统")
    @RequestMapping(value = "", method = RequestMethod.POST)
    public Wrapper save(@RequestBody SystemDto system) {
        HyValidatorFactory.validate(system);
        System res = systemService.save(system);
        return WrapMapper.ok(res);
    }
}
